home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pasmouse.zip / MOUSE1.PAS < prev   
Pascal/Delphi Source File  |  1991-05-02  |  2KB  |  110 lines

  1. {
  2. Msg #:  604                       PASCAL Subboard
  3.  From:  RON PRITCHETT             Sent: 04-30-91 21:10
  4.    Re:  MOUSE CODE PROBLEM
  5.  
  6. Ok, Here's some code I'm having a problem with. The "pluses" I draw
  7. upon a left mouse button click are erased when the mouse is moved.
  8. Anyone got an answer?
  9.  
  10.  * Origin: Ronnue's Realm - Columbia, SC (803)781-2440
  11.  
  12. begin code:
  13. }
  14. program blah;
  15.  
  16. uses dos,crt,graph,mouse,drivers;
  17.  
  18. type ButtonRec=record
  19.         Name: string[25];
  20.         xcoord,
  21.         ycoord: integer;
  22.      end;
  23.  
  24.      ButtonType=array[1..50] of ButtonRec;
  25.  
  26.      MouseObj=object
  27.        num_buttons: word;            { # of buttons on the mouse }
  28.        error,                        { error on init or not }
  29.        pressed1,                     { if button #1 pressed }
  30.        pressed2,                     { if button #2 pressed }
  31.        pressed3:     boolean;        { if button #3 pressed }
  32.        xcoord,
  33.        ycoord:       word;
  34.  
  35.        procedure MouseOn;
  36.        procedure GetPressed;
  37.        procedure MouseOff;
  38.        procedure GetCoords;
  39.      end; { object MouseObj }
  40.  
  41. var  Buttons: ButtonType;
  42.      gmode,gdriver: integer;
  43.      Rodent:        MouseObj;
  44.  
  45.  
  46. procedure MouseObj.MouseOn;
  47.  
  48. begin
  49.   InitMouse(num_buttons,error);
  50.   ShowPointer;
  51.   pressed1:=false;
  52.   pressed2:=false;
  53.   pressed3:=false;
  54. end;
  55.  
  56.  
  57. procedure MouseObj.GetPressed;
  58.  
  59. var stat,c,h,v: word;
  60.  
  61. begin
  62.   getpressinfo(leftbutton,stat,c,h,v);
  63.   Pressed1:=(stat and $01)=LeftButton;
  64.   Pressed2:=(stat and $04)=CenterButton;
  65.   Pressed3:=(stat and $02)=RightButton;
  66. end;
  67.  
  68. procedure MouseObj.MouseOff;
  69.  
  70. begin
  71.   HidePointer;
  72. end;
  73.  
  74. procedure MouseObj.GetCoords;
  75.  
  76. begin
  77.   GetMousePosition(num_buttons,xcoord,ycoord);
  78. end;
  79.  
  80.  
  81.  
  82. begin
  83.   SetupDrivers;
  84.   gmode:=0;
  85.   gdriver:=0;
  86.   initgraph(gdriver,gmode,'');
  87.   Rodent.MouseOn;
  88.   repeat
  89.     Rodent.GetPressed;
  90.     if Rodent.pressed1 then
  91.       begin
  92.         Rodent.GetCoords;
  93.         setcolor(13);
  94.  
  95. line(Rodent.xcoord-5,Rodent.ycoord,Rodent.xcoord+5,Rodent.ycoord);
  96.  
  97. line(Rodent.xcoord,Rodent.ycoord-5,Rodent.xcoord,Rodent.ycoord+5);
  98.      end;
  99.     delay(100);
  100.   until Rodent.pressed3;
  101.   Rodent.MouseOff;
  102.   closegraph;
  103. end.
  104.  
  105.  
  106. {
  107. so... what's wrong?
  108.  
  109. }
  110.